/*
 * Created by Jaren at 2023/9/25 9:23
 */
import 'dart:typed_data';

class ElephantConstant {
  /*  Message Constant START  */
  static const int msgHeadBytesLength = 2;
  static const int msgCheckBytesLength = 2;

  /// 消息头
  static final Uint8ClampedList msgHeadBytes = Uint8ClampedList.fromList(const [0x55, 0xAB]);

  /// 最少有效数据包长度 <br/>
  /// msg head + length + encrypt + device + function + msg check
  static const int msgMinLength = msgHeadBytesLength + 1 + 1 + 1 + 1 + msgCheckBytesLength;

  /// 有效消息长度的起始位置 <br/>
  /// msg head + msg length + encrypt + device
  static const int msgValidDataIndex = msgHeadBytesLength + 1 + 1 + 1;

  /// 消息长度位
  static const int msgLengthIndex = 2;

  /// 密钥位置
  static const int msgCryptIndex = 3;

  /*  Message Constant END  */

  /* **************************************************** */

  /*  Message Function Code START  */

  /// 读取信息
  static const int funcReadInfo = 0x01;

  /// 写入信息
  static const int funcWriteInfo = 0x03;

  /// 读取日志
  static const int funcLog = 0x05;

  /// 固件升级 - 通知设备准备升级
  static const int funcFwUpdatePrepare = 0x07;

  /// 固件升级 - 传输文件
  static const int funcFwUpdateFileTransfer = 0x08;

  /// 固件升级 - 文件校验
  static const int funcFwUpdateFileCheck = 0x09;

  /// 固件升级 - 重启使能新固件
  static const int funcFwUpdateReboot = 0x0A;

  /*  Message Function Code END  */

  /* **************************************************** */

  /*  Message Function Extra Code START  */

  static const int extraFuncDriverBoardVersion = 0x01;
  static const int extraFuncInitInfo = extraFuncDriverBoardVersion;
  static const int extraFuncSn = 0x16;
  static const int extraFuncProductModel = 0x1F;
  static const int extraFuncErrorCode = 0x29;
  static const int extraFuncRealTimeInfo = 0x2D;
  static const int extraFuncBatteryLevel = 0x30;
  static const int extraFuncTotalRideMileage = 0x37;
  static const int extraFuncDynamicSpeedLimit = 0xBA;
  static const int extraFuncBtVersion = 0x66;
  static const int extraFuncLock = 0x6E;
  static const int extraFuncUnlock = 0x6F;
  static const int extraFuncEnableSpeedLimit = 0x70;
  static const int extraFuncSpeedLimit = 0x72;
  static const int extraFuncPowerOff = 0x77;
  static const int extraFuncTurningSensitivity = 0x9F;
  static const int extraFuncPedalSensitivity = 0xA0;
  static const int extraFuncBalanceAngle = 0xA1;
  static const int extraFuncLightEffectMode = 0xC4;
  static const int extraFuncLightEffectColor = 0xC6;
  static const int extraFuncSideWheelLightEffectState = 0xC5;
  static const int extraFuncFeatures = 0xD1;
  static const int extraFuncLightState = 0xD2;

  /*  Message Function Extra Code END  */

  /// 通讯对象 - 主板
  static const int commDeviceController = 0x0A;

  /// 通讯对象 - 蓝牙板
  static const int commDeviceBt = 0x0B;
}
